<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/
session_start();
include("conexion.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
	date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
	$usuario = $_SESSION['name'];
	$fecha = date("Y-m-d H:i:s");
	$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Visualizar estadisticas de grado' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}

$Periodo=$_GET['Periodo'];
$Grado=$_GET['Grado'];
$Seccion=$_GET['Seccion'];

//estadisticas

if($Periodo && $Grado && $Seccion){	
$rs=mysql_query("SELECT Sexo, COUNT(*) FROM estudiante WHERE Cedula_e IN(SELECT Cedula_e FROM inscripcion WHERE Periodo='$Periodo' AND Grado='$Grado' AND Seccion='$Seccion') GROUP BY Sexo");


include "libchart/classes/libchart.php";

	$chart = new PieChart();
	$dataSet = new XYDataSet();

while ($row=mysql_fetch_array($rs)){
	$dataSet->addPoint(new Point("$row[0]: $row[1]",$row[1]));
}

	$chart->setDataSet($dataSet);
	$chart->setTitle("Cantidad de varones y hembras");
	$chart->render("graficos/ListadoEstudiantes.png");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Estadisticas Grado</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css" />
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script> 
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
});

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});
</script>
<!-- fin botones-->
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>
</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">

<blockquote><h2 align="center">ESTADISTICAS GRADO</h2></blockquote>
			<form action="EstadisticasGrado.php" method="GET">
			<fieldset>
			<legend align=left><b><font size=2>BUSCADOR</font></b></legend>
			<table width=100% cellspacing=5 cellpadding=0 border=0>
			<tr>
			<td align=center><select name="Grado"><option>Grado</option>
												<option <?php if ($Grado=='Primer'){ echo "Selected"; } ?>>Primer</option>
												<option <?php if ($Grado=='Segundo'){ echo "Selected"; } ?>>Segundo</option>
												<option <?php if ($Grado=='Tercer'){ echo "Selected"; } ?>>Tercer</option>
												<option <?php if ($Grado=='Cuarto'){ echo "Selected"; } ?>>Cuarto</option>
												<option <?php if ($Grado=='Quinto'){ echo "Selected"; } ?>>Quinto</option>
												<option <?php if ($Grado=='Sexto'){ echo "Selected"; } ?>>Sexto</option></select>
											<select name="Seccion">
												<option>Secci&oacute;n</option>
												<option <?php if ($Seccion=='A'){ echo "Selected"; } ?>>A</option>
												<option <?php if ($Seccion=='B'){ echo "Selected"; } ?>>B</option>
												<option <?php if ($Seccion=='C'){ echo "Selected"; } ?>>C</option>
												<option <?php if ($Seccion=='D'){ echo "Selected"; } ?>>D</option>
												<option <?php if ($Seccion=='E'){ echo "Selected"; } ?>>E</option></select>
								<select name="Periodo"><option>Periodo</option><option><?php $anio=2000; $anio2=$anio+1; while($anio<date(Y)+1){ echo "<option "; if ($Periodo=="$anio - $anio2"){ echo "Selected"; } echo "> $anio - $anio2 </option>"; $anio++; $anio2++; } ?></option></select>
								<input class=button type=submit value=Buscar></td>
			</tr>
			</table>
			</fieldset>
			</form>

<div class="post">
<span></span></div>
<form action="EstadisticasGrado.php" method="GET">
		<?php if($rs){
			echo "<fieldset>";
			echo "<legend align=left><b><font size=2>ESTADISTICAS</font></b></legend>";
			echo "<table width=100%  cellspacing=5 cellpadding=0 border=0>";
			echo "<tr>";
			echo "<td>Periodo $Periodo</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td>$Grado grado</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td>Secci&oacute;n $Seccion</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td><br></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td><img alt='Pie chart' src='graficos/ListadoEstudiantes.png' width=100% style='border: 1px solid gray;'/></td>";
			echo "</tr>";
			echo "</table>";
			echo "</fieldset>";
			echo "<div class='post'>";
			echo "<span></span></div>";
			echo "<div name=botonera align=center>";
			echo "<input type=hidden name=Periodo value='$Periodo'>";
			echo "<input type=hidden name=Grado value=$Grado>";
			echo "<input type=hidden name=Seccion value=$Seccion>";
			echo "<input class=button type=button value=Volver onClick=\"location='EstadisticasEstudiante.php'\">";
			echo "</div>";
		} ?>
</form>
</div>
<div class="post_b">
<span></span></div>
</div>


</div>

<div class="post">
<div class="post_h">

</div>


</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
